package com.shqcjd.preinstallmobile.ui.adapter;

import android.content.Context;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.shqcjd.preinstallmobile.R;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class EquipmentRecordAbnormalAdapter extends BaseQuickAdapter<String, EquipmentRecordAbnormalAdapter.ViewHolder> {
    private Context context;

    public EquipmentRecordAbnormalAdapter(@Nullable List<String> data, Context context) {
        super(R.layout.item_inspection_record, data);
        this.context = context;
    }

    @Override
    protected void convert(ViewHolder helper, String item) {
        RequestOptions options = new RequestOptions()
                .placeholder(R.mipmap.ic_default_small)	//加载成功之前占位图
                .error(R.mipmap.ic_default_small)	//加载错误之后的错误图
                .centerCrop();//指定图片的缩放类型为centerCrop （等比例缩放图片，直到图片的宽高都
        Glide.with(context)
                .load(item)
                .apply(options)
                .into(helper.ivImg);

    }

    class ViewHolder extends BaseViewHolder {
        @BindView(R.id.iv_img)
        ImageView ivImg;

        public ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }
    }

}
